package io.github.doc.action.element;

import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameterList;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;

import java.util.Arrays;
import java.util.List;

/**
 * <p>Company: 深圳振瀚信息技术有限公司成都分公司 </p>
 * <p>Description: </p>
 *
 * @author ZH.Team
 * @version 1.0.0
 * @email "mailto:ZH.Team@zhxx.com"
 * @date 2025.01.05 17:37
 * @since y.y.y
 */
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
public class JavaMethodElement extends AbstractElement<PsiMethod> {

    /**
     * Class name
     */
    private String methodName;

    /**
     * Params
     */
    private List<Param> params;

    /**
     * Build
     *
     * @param psiMethod psi method
     * @return the java method element
     * @since y.y.y
     */
    public static JavaMethodElement builder(PsiMethod psiMethod) {
        String name = psiMethod.getName();
        PsiParameterList parameterList = psiMethod.getParameterList();
        List<Param> params = Arrays.stream(parameterList.getParameters()).map(parameter -> {
            Param param = new Param();
            param.setName(parameter.getName());
            return param;
        }).toList();
        return null;
    }

    /**
     * <p>Company: 深圳振瀚信息技术有限公司成都分公司 </p>
     * <p>Description: </p>
     *
     * @author ZH.Team
     * @version 1.0.0
     * @email "mailto:ZH.Team@zhxx.com"
     * @date 2025.01.27 19:01
     * @since y.y.y
     */
    @Data
    public static class Param {

        /**
         * Name
         */
        private String name;

        /**
         * Doc
         */
        private String doc;

        /**
         * Type
         */
        private String type;
    }
}
